package hku.cs.lunuo.rank;

import hku.cs.lunuo.rank.model.Statistic;

import java.util.HashMap;

public class CDStatistic extends Statistic {
	private HashMap<String, HashMap<String, HashMap<String, StatisticProperty>>> tfData = 
		new HashMap<String, HashMap<String, HashMap<String, StatisticProperty>>>();

	private HashMap<String, HashMap<String, HashMap<String, Integer>>> obData = 
		new HashMap<String, HashMap<String, HashMap<String, Integer>>>();

	public void add(String className, String methodName, String es, boolean tof) {
		HashMap<String, HashMap<String, StatisticProperty>> HES;
		HES = tfData.get(className);
		if(HES == null) {
			HES = new HashMap<String, HashMap<String, StatisticProperty>>();
		}
		HashMap<String, StatisticProperty> inHES;
		inHES = HES.get(methodName);
		if(inHES==null) {
			inHES = new HashMap<String, StatisticProperty>();
		}
		StatisticProperty cbs = inHES.get(es);
		if(cbs == null) {
			cbs = new StatisticProperty();
		}
		
		cbs.add(tof);
		
		String xx = es.split(">")[0];
		
		HashMap<String, HashMap<String, Integer>> HTS;
		HTS = obData.get(className);
		if(HTS == null)
			HTS = new HashMap<String, HashMap<String,Integer>>();
		
		HashMap<String, Integer> inHTS;
		inHTS = HTS.get(methodName);
		if(inHTS == null) {
			inHTS = new HashMap<String, Integer>();
		}
		Integer txx = inHTS.get(xx);
		if(txx == null)
			txx = 0;
		txx++;
		inHTS.put(xx, txx);
	}

}
